Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 4f21d778986c372d829a22230e005afbaabba942


Parents : c4c64b7
Author : Sudo-Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-01-01T17:34:56-06:00

feat(database): update schema to include lxmf_telemetry table and associated indexes for improved telemetry data management

Changes

1 files changed, 48 insertions(+), 1 deletions(-)


Diff

diff --git a/meshchatx/src/backend/database/schema.py b/meshchatx/src/backend/database/schema.py
index 4f0d9bd3..9777936a 100644
--- a/meshchatx/src/backend/database/schema.py
+++ b/meshchatx/src/backend/database/schema.py
@@ -2,7 +2,7 @@ from .provider import DatabaseProvider
class DatabaseSchema:
- LATEST_VERSION = 14
+ LATEST_VERSION = 15
def __init__(self, provider: DatabaseProvider):
self.provider = provider
@@ -212,6 +212,19 @@ class DatabaseSchema:
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
""",
+ "lxmf_telemetry": """
+ CREATE TABLE IF NOT EXISTS lxmf_telemetry (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ destination_hash TEXT,
+ timestamp REAL,
+ data BLOB,
+ received_from TEXT,
+ physical_link TEXT,
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ UNIQUE(destination_hash, timestamp)
+ )
+ """,
}
for table_name, create_sql in tables.items():
@@ -246,6 +259,16 @@ class DatabaseSchema:
self.provider.execute(
"CREATE UNIQUE INDEX IF NOT EXISTS idx_notification_viewed_state_dest_hash_unique ON notification_viewed_state(destination_hash)"
)
+ elif table_name == "lxmf_telemetry":
+ self.provider.execute(
+ "CREATE INDEX IF NOT EXISTS idx_lxmf_telemetry_destination_hash ON lxmf_telemetry(destination_hash)"
+ )
+ self.provider.execute(
+ "CREATE INDEX IF NOT EXISTS idx_lxmf_telemetry_timestamp ON lxmf_telemetry(timestamp)"
+ )
+ self.provider.execute(
+ "CREATE UNIQUE INDEX IF NOT EXISTS idx_lxmf_telemetry_dest_ts_unique ON lxmf_telemetry(destination_hash, timestamp)"
+ )
def migrate(self, current_version):
if current_version < 7:
@@ -443,6 +466,30 @@ class DatabaseSchema:
"CREATE UNIQUE INDEX IF NOT EXISTS idx_notification_viewed_state_dest_hash_unique ON notification_viewed_state(destination_hash)"
)
+ if current_version < 15:
+ self.provider.execute("""
+ CREATE TABLE IF NOT EXISTS lxmf_telemetry (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ destination_hash TEXT,
+ timestamp REAL,
+ data BLOB,
+ received_from TEXT,
+ physical_link TEXT,
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ UNIQUE(destination_hash, timestamp)
+ )
+ """)
+ self.provider.execute(
+ "CREATE INDEX IF NOT EXISTS idx_lxmf_telemetry_destination_hash ON lxmf_telemetry(destination_hash)"
+ )
+ self.provider.execute(
+ "CREATE INDEX IF NOT EXISTS idx_lxmf_telemetry_timestamp ON lxmf_telemetry(timestamp)"
+ )
+ self.provider.execute(
+ "CREATE UNIQUE INDEX IF NOT EXISTS idx_lxmf_telemetry_dest_ts_unique ON lxmf_telemetry(destination_hash, timestamp)"
+ )
+
# Update version in config
self.provider.execute(
"INSERT OR REPLACE INTO config (key, value, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP)",


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────